package com.shop.servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.shop.service.AccountService;


@WebServlet("/registerServlet")
public class RegisterServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    
    public RegisterServlet() {
        super();
    }

	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		
		AccountService service = new AccountService();
		boolean checkAdmin = service.checkAccount(request);
		if (checkAdmin) {
			System.out.println("注册成功");
//			response.sendRedirect("login.jsp");
			response.getWriter().append("login.jsp");
		}else {
			System.out.println("注册失败，请重新注册");
//			response.sendRedirect("error.jsp");
			response.getWriter().append("error.jsp");
		}
		
	
		
	}

	
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
